<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h1>异步请求测试项目</h1>
<div>
    {{info}}
    <input type="button" value="异步请求" @click="f()">
</div>
<!--引入axios和vue框架-->
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
<script src="https://cdn.staticfile.org/vue/2.6.14/vue.min.js"></script>
<script>
    let v = new Vue({
        el: "body>div",
        data: {
            info: "异步测试"
        },
        methods: {
            f() {
                //发出异步get请求
                axios.get("/helloAxios").then(function (response) {
                    //response是响应对象,response.data得到服务器响应的数据
                    alert(response.data);
                    v.info=response.data;
                });
            }
        }
    })
</script>
</body>
</html>